function init(){
	var supportAcqId = document.Form2102.supportAcqId.value;
	var codeKey = document.Form2102.codeKey;
	for(var i=0;i<codeKey.length;i++){
		if(supportAcqId == "ALL"){
			codeKey[i].checked = true;
		}else if(supportAcqId.indexOf(codeKey[i].value + "^")!= -1){
			codeKey[i].checked = true;
		}else{
			codeKey[i].checked = false;
		}
	}
}

function hideBlock(){  
    jQuery.unblockUI();  
 }
 
 
function control2102(){
	if(document.Form2102.chnlId2.value.trim() == ""){
		if(Form2102.chnlId.value == "onselect"){
			alert("请选择代理商");
			Form2102.chnlId.focus();
			return;
		}
	}
	
	$.blockUI({ message: ' <img src="images/loading.gif" />' });
	//setTimeout('hideBlock()',1000);//1000毫秒后调用hideBlock()
	document.forms[0].action = "perform2102.do";
	document.forms[0].submit();
}

function perform2102() {
	if($("input[name='codeKey'][checked]").val() == undefined){
		alert( "请至少选择一个支持的收单机构！" ) ;
		return ;
	}
	
	if( document.Form2102.provId.value == "onselect" ){
		alert( "请选择地址省份！" ) ;
		document.Form2102.provId.focus() ;
		return ;
	}
	
	if( document.Form2102.areaId.value == "onselect" ){
		alert( "请选择地址城市！" ) ;
		document.Form2102.areaId.focus() ;
		return ;
	}
	
	if( document.Form2102.chnlAddr.value.trim() == "" ){
		alert( "请输入详细地址！" ) ;
		document.Form2102.chnlAddr.focus() ;
		return ;
	}
	
	if( document.Form2102.chnlZip.value.trim() == "" ){
		alert( "请输入邮编！" ) ;
		document.Form2102.chnlZip.focus() ;
		return ;
	}
	
	if( document.Form2102.chnlZip.value.length!=6||
		!isNumber(document.Form2102.chnlZip)){
		alert( "邮编格式错误！" ) ;
		document.Form2102.chnlZip.focus() ;
		return ;
	}
	
	
	if( document.Form2102.chnlContactRen.value.trim() == "" ){
		alert( "请输入联系人！" ) ;
		document.Form2102.chnlContactRen.focus() ;
		return ;
	}
	
	if( document.Form2102.chnlMp.value.trim() == "" ){
		alert( "请输入联系人手机！" ) ;
		document.Form2102.chnlMp.focus() ;
		return ;
	}
	
	if( document.Form2102.chnlAddr.value.trim() == "" ){
		alert( "请输入详细地址！" ) ;
		document.Form2102.chnlAddr.focus() ;
		return ;
	}
	 
	
	if( document.Form2102.posSaleLevel.value == "onselect" ){
		alert( "请选择机具采购级别！" ) ;
		document.Form2102.posSaleLevel.focus() ;
		return ;
	}
	
	if( document.Form2102.openProvId.value == "onselect" ){
		alert( "请选择开户地省份！" ) ;
		document.Form2102.openProvId.focus() ;
		return ;
	}
	
	if( document.Form2102.openAreaId.value == "onselect" ){
		alert( "请选择开户地城市！" ) ;
		document.Form2102.openAreaId.focus() ;
		return ;
	}
	
	if(Form2102.needInvoice[0].checked == false&&
			Form2102.needInvoice[1].checked == false){
		alert( "请选择是否需开具发票！" ) ;
		return ;
	}
	
	
	if( document.Form2102.openBankId.value == "onselect" ){
		alert( "请选择开户银行！" ) ;
		document.Form2102.openBankId.focus() ;
		return ;
	}
	
	if( document.Form2102.openBranchName.value.trim() == "" ){
		alert( "请输入支行名称！" ) ;
		document.Form2102.openBranchName.focus() ;
		return ;
	}
	
	if( document.Form2102.openAcctName.value.trim() == "" ){
		alert( "请输入账户名称！" ) ;
		document.Form2102.openAcctName.focus() ;
		return ;
	}
	
	if( document.Form2102.openAcctId.value.trim() == "" ){
		alert( "请输入账号！" ) ;
		document.Form2102.openAcctId.focus() ;
		return ;
	}
	
	if( document.Form2102.blOperId.value == "onselect" ){
		alert( "请选择所属销售！" ) ;
		document.Form2102.blOperId.focus() ;
		return ;
	}
	
	if( document.Form2102.agreeNo.value.trim() == "" ){
		alert( "请输入合同编号！" ) ;
		document.Form2102.agreeNo.focus() ;
		return ;
	}
	
	if( document.Form2102.joinAmt.value.trim() == "" ){
		alert( "请输入加盟费！" ) ;
		document.Form2102.joinAmt.focus() ;
		return ;
	}
	
	if ( isLegalAmt ( document.Form2102.joinAmt ) ){
		document.Form2102.joinAmt.value = getAmtWithTwoDecimal( document.Form2102.joinAmt ) ;
	}
	else{
		alert( "加盟费金额格式错误！" ) ;
		document.Form2102.joinAmt.focus() ;
		return ;
	}
	
	$.blockUI({ message: ' <img src="images/loading.gif" />' });
	Form2102.action = "perform2102_1.do" ;
	document.Form2102.submit();
}

function perform2102_2(){
	if(confirm("确认删除此代理？")){
		$.blockUI({ message: ' <img src="images/loading.gif" />' });
		Form2102.action = "perform2102_2.do" ;
		document.Form2102.submit();
	}
	
}

function control2102_1(){
	if(document.Form2102.chnlId2.value.trim() == ""){
		if(Form2102.chnlId.value == "onselect"){
			alert("请选择代理商");
			Form2102.chnlId.focus();
			return;
		}
	}
	
	Form2102.action = "perform2102_3.do" ;
	document.Form2102.submit();
}

function perform2102_3(){
	var clientFile  = document.getElementsByName("logoPath")[0].value;
	var fileType = clientFile.split(".");
	
	if(clientFile.length ==0){
		alert("请选择图片文件");
		return;
	}
	
	if(fileType[1].toLowerCase() != "jpg" && fileType[1].toLowerCase() != "png" && fileType[1].toLowerCase() != "gif"){
		alert("请选择jpg,png,gif格式的图片文件上传！");
		return;
	}
	
	Form2102.action = "perform2102_4.do" ;
	document.Form2102.submit();
}